﻿@{
    ViewData["Title"] = "WarehouseSetAddIndex";
    Layout = null;
}
<link href="~/libs/layui-v2.5.6/layui/css/layui.css" rel="stylesheet" />
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <label class="layui-form-label">仓库编码</label>
            <div class="layui-input-block">
                <input type="text" id="setCode" name="setCode" lay-verify="required" placeholder="请输入仓库编码" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">仓库名称</label>
            <div class="layui-input-block">
                <input type="text" id="setName" name="setName" lay-verify="required" placeholder="请输入仓库名称" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">位置</label>
            <div class="layui-input-block">
                <input type="text" id="setUnit" name="setUnit" lay-verify="required" placeholder="请输入仓库简称" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">面积</label>
            <div class="layui-input-block">
                <input type="number" lay-affix="number" placeholder="" name="setCapacity" id="setCapacity" value="0" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">负责人</label>
            <div class="layui-input-block">
                <input type="text" id="setPeople" name="setPeople" lay-verify="required" placeholder="请输入负责人" autocomplete="off" class="layui-input">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">是否冻结</label>
            <div class="layui-input-block">
                <input type="radio" name="isNot" value="true" title="是" checked>
                <input type="radio" name="isNot" value="false" title="否">
            </div>
        </div>

        <div class="layui-form-item">
            <label class="layui-form-label">备注</label>
            <div class="layui-input-block">
                <textarea name="result" id="result" placeholder="多行文本框" class="layui-textarea"></textarea>
            </div>
        </div>

        <div class="layui-form-item">
            <div class="layui-input-block">
                <button type="submit" class="layui-btn" lay-submit lay-filter="demo1">立即提交</button>
                <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                <button type="reset" class="layui-btn layui-btn-primary" onclick="closeWorkstation()">返回</button>
            </div>
        </div>
    </form>

<script src="~/libs/layui-v2.5.6/layui/layui.js"></script>
<script src="~/libs/jquery/jquery.js"></script>
    <script>
        layui.use(['form', 'laydate', 'util'], function(){
          var form = layui.form;
          var layer = layui.layer;

          // 页面加载完成后执行的函数
          $(function () {
            $('#primaryUnit').val(1);
          });

          // 提交事件
          form.on('submit(demo1)', function(data){
            var field = data.field; // 获取表单字段值
     
            field.isNot = Boolean(field.isNot);
            $.ajax({
                url:'/WarehouseSet/AddWarehouseSet',
                type:'post',
                data:field,
                dataType:'json',
                success:function(res){
                    if(res.code==1){
                        layer.alert('添加成功！');
                        closeWorkstation();
                    }
                    if(res.code==-100){
                        layer.alert('已经有此单位名称！');
                    }
                }
            });
            return false; // 阻止默认 form 跳转
          });
        });

        // 关闭弹框
        function closeWorkstation() {
            var index = parent.layer.getFrameIndex(window.name); //先得到当前的索引
            parent.layer.close(index); //再执行关闭
        }
    </script>




